package com.kc.web.controller.business;

import com.kc.business.domain.BizShipping;
import com.kc.business.domain.BizVideo;
import com.kc.business.service.IBizVideoSeivice;
import com.kc.common.annotation.Log;
import com.kc.common.annotation.RepeatSubmit;
import com.kc.common.core.controller.BaseController;
import com.kc.common.core.domain.AjaxResult;
import com.kc.common.core.page.TableDataInfo;
import com.kc.common.enums.BusinessType;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 视频管理
 */
@RestController
@RequestMapping("/business/video")
public class BizVideoController extends BaseController {
    @Resource
    private IBizVideoSeivice bizVideoSeivice;

    @PreAuthorize("@ss.hasPermi('business:video:add')")
    @Log(title = "视频管理", businessType = BusinessType.INSERT)
    @PostMapping
    @RepeatSubmit
    public AjaxResult add(@Validated @RequestBody BizVideo bizVideo) {
        return toAjax(bizVideoSeivice.add(bizVideo));
    }
    @PreAuthorize("@ss.hasPermi('business:video:edit')")
    @Log(title = "视频管理", businessType = BusinessType.UPDATE)
    @PutMapping
    @RepeatSubmit
    public AjaxResult edit(@Validated @RequestBody BizVideo bizVideo) {
        return toAjax(bizVideoSeivice.edit(bizVideo));
    }
    @PreAuthorize("@ss.hasPermi('business:video:remove')")
    @Log(title = "视频管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{id}")
    @RepeatSubmit
    public AjaxResult remove(@PathVariable Integer id) {
        BizVideo bizVideo = new BizVideo();
        bizVideo.setId(id);
        bizVideo.setIsDeleted(1);
        return toAjax(bizVideoSeivice.edit(bizVideo));
    }

    @PreAuthorize("@ss.hasPermi('business:video:list')")
    @GetMapping
    public TableDataInfo getList(BizVideo bizVideo){
        startPage();
        return getDataTable(bizVideoSeivice.getList(bizVideo));
    }
    @PreAuthorize("@ss.hasPermi('business:video:info')")
    @GetMapping("/getInfo")
    public AjaxResult getInfo(BizVideo bizVideo){
        return AjaxResult.success(bizVideoSeivice.getInfo(bizVideo));
    }
}
